#!/usr/bin/env python3

import math
import sys

# 文件名
filename = "numbers.txt"

# 检查文件是否存在
try:
    with open(filename, 'r') as file:
        numbers = file.readlines()
except FileNotFoundError:
    print(f"文件 {filename} 不存在。")
    sys.exit(1)

# 计算对数的平均值
sum_log = 0
count = 0

for number in numbers:
    try:
        num = float(number.strip())
        if num <= 0:
            print(f"文件中包含非正数: {number.strip()}")
            continue
        log_value = math.log(num)
        sum_log += log_value
        count += 1
    except ValueError:
        print(f"文件中包含无效数字: {number.strip()}")
        continue

if count > 0:
    avg_log = sum_log / count
    print(f"对数的平均值是: {avg_log}")
else:
    print("文件中没有有效数字。")

